<template>
  <footer class="footer">
    <span class="todo-count">剩余<strong> {{ surplus }} </strong></span>
    <ul class="filters">
      <li>
        <a @click="$emit('setActive','all')" :class="{selected:active==='all'}" href="javascript:;" >全部</a>
      </li>
      <li>
        <a @click="$emit('setActive','undone')" :class="{selected:active==='undone'}" href="javascript:;">未完成</a>
      </li>
      <li>
        <a @click="$emit('setActive','done')" :class="{selected:active==='done'}" href="javascript:;" >已完成</a>
      </li>
    </ul>
    <button class="clear-completed" @click="clearDone">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props:['arr','active'],
  computed:{
    // 剩余数量
    surplus(){
      return this.arr.filter(item=>!item.isDone).length
    }
  },
  methods:{
    // 清除已完成
    clearDone(){
      const undone=this.arr.filter(item=>!item.isDone)
      this.$emit('onClear',undone)
    }
  }
}
</script>